package com.sise.stuteaintersys.mapper;

import com.sise.stuteaintersys.bean.entity.Question;
import com.sise.stuteaintersys.bean.entity.QuestionExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface QuestionMapper {
    int countByExample(QuestionExample example);

    int deleteByExample(QuestionExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Question record);

    /**
     *
     *
     *@param
     *@return
     *@author wdj
     *@dateTime 2019/1/10 21:11
     */
    int insertBatch(List<Question> list);

    int insertSelective(Question record);

    List<Question> selectByExample(QuestionExample example);

    Question selectByPrimaryKey(Integer id);
    /**
     *
     *
     *@param examType 试卷类型
     *@return List<Qusetion>
     *@date 2019/1/3
     *@time 11:58
     */
    @Select("select * from question where id in (select question_id from exam where exam_type=#{examType})")
    List<Question> selectExam(String examType);

    @Select("select id from question where course_id=#{courseId} order by RAND() LIMIT 10")
    List<Question> selectRandom(Integer courseId);

    int updateByExampleSelective(@Param("record") Question record, @Param("example") QuestionExample example);

    int updateByExample(@Param("record") Question record, @Param("example") QuestionExample example);

    int updateByPrimaryKeySelective(Question record);

    int updateByPrimaryKey(Question record);

}